package com.cskaoyan.controller;

import com.cskaoyan.bean.common.BaseRespVo;

import com.cskaoyan.bean.vo.zxw.MarketExpressConfigVo;
import com.cskaoyan.bean.vo.zxw.MarketMallConfigVo;
import com.cskaoyan.bean.vo.zxw.MarketOrderConfigVo;
import com.cskaoyan.bean.vo.zxw.MarketWxConfigVo;
import com.cskaoyan.service.AdminConfigService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 配置管理模块
 * @author 曾添乐啦
 * @since 2022/12/29 15:19
 */

@RestController
@RequestMapping("admin/config")
public class AdminConfigController {

    @Autowired
    AdminConfigService adminConfigService;

    /**
     * 请求参数是JSON数据，需要用对象接收
     * market_mall_address: "test-demo1"
     * market_mall_latitude: "31.201900"
     * market_mall_longitude: "888"
     * market_mall_name: "商场配置test"
     * market_mall_phone: "19900092220"
     * market_mall_qq: "12312312@qq.com"
     * errmsg: "成功"
     * errno: 0
     * 这里实际上传入请求参数没有意义，通过观察可以发现它的请求参数和响应参数是一样的
     * <p>
     * 响应参数
     * {"errno":0,
     * "data":{
     * "market_mall_longitude":"888",
     * "market_mall_latitude":"31.201900",
     * "market_mall_address":"test-demo1",
     * "market_mall_qq":"12312312@qq.com",
     * "market_mall_phone":"19900092220",
     * "market_mall_name":"商场配置test"},
     * "errmsg":"成功"}
     *
     * @return
     */
    //商场配置

    @RequestMapping("mall")
    public BaseRespVo mallConfig() {

        MarketMallConfigVo mallConfigVo = adminConfigService.findmallConfig();
        return BaseRespVo.ok(mallConfigVo);
    }

    //运费配置

    @RequestMapping("express")
    public BaseRespVo expressConfig() {

        MarketExpressConfigVo marketExpressVo = adminConfigService.findexpressConfig();
        return BaseRespVo.ok(marketExpressVo);
    }

    //订单配置

    @RequestMapping("order")
    public BaseRespVo orderConfig() {
        MarketOrderConfigVo marketOrderConfigVo = adminConfigService.findorderConfig();
        return BaseRespVo.ok(marketOrderConfigVo);
    }

    //小程序配置

    @RequestMapping("wx")
    public BaseRespVo wxConfig() {

        MarketWxConfigVo marketWxConfigVo = adminConfigService.findwxConfig();
        return BaseRespVo.ok(marketWxConfigVo);
    }
}
